import { ApiProperty } from "@nestjs/swagger"
import { Type } from "class-transformer"
import { IsInt, IsNotEmpty, IsOptional } from "class-validator"


export class CreateArticleDto {
    @ApiProperty({ example: '历史', description: '文章名称' })
    @IsNotEmpty({
        message: '名称不能为空'
    })
    title: string

    @ApiProperty({ example: 'address', description: '文章内容的地址' })
    @IsOptional()
    content: string

    @ApiProperty({ example: '0', description: '重点文章的级别' })
    @IsOptional()
    keyLevel: string

    @ApiProperty({ example: 'draft/publish', description: '文章状态' })
    @IsOptional()
    status: string

    @ApiProperty({ example: '100000', description: '父级id' })
    @Type(() => Number)
    @IsInt()
    subCategoryId: number

    @ApiProperty({ example: '100000', description: '用户id' })
    @IsOptional()
    @Type(() => Number)
    @IsInt()
    userId: number
}

export class FindManyDto {
    @ApiProperty({ example: '1111', description: '类别id' })
    @IsNotEmpty({
        message: '类别id不能为空'
    })
    @Type(() => Number)
    @IsInt()
    subCategoryId: number

    @ApiProperty({ example: '100000', description: '用户id' })
    @IsOptional()
    @Type(() => Number)
    @IsInt()
    userId: number
}

export class FindKeyArticleDto {
    @ApiProperty({ example: '100000', description: '类别id' })
    @Type(() => Number)
    @IsInt()
    parentCatId: number

    @ApiProperty({ example: '100000', description: '用户id' })
    @IsOptional()
    @Type(() => Number)
    @IsInt()
    userId: number
}

export class EditArticleDto extends CreateArticleDto {
    @ApiProperty({ example: '1111', description: '文章id' })
    @IsNotEmpty({
        message: '文章id不能为空'
    })
    @Type(() => Number)
    @IsInt()
    id: number
}

export class DeleteArticleDto {
    @ApiProperty({ example: '1111', description: '文章id' })
    @IsNotEmpty({
        message: '文章id不能为空'
    })
    @Type(() => Number)
    @IsInt()
    id: number
}
